<?php
	
	namespace Aspic\Form\Element;
	
	use Aspic as A;
	use Aspic\Security\Token as SToken;
	
	/**
	* Represent a Token (hash) anti CRSF
	 * @see Security\Token
	*/
	class Token extends HiddenTextBox {
		const ALLOW_DYNAMIC_ADD = false;
		
		protected $_token;

		public function __construct($name, &$store, $expiresIn, $regenerateTokenIfValid, $salt = '') {
			$token = new SToken($store, $expiresIn, $regenerateTokenIfValid, null, $salt);
			
			parent::__construct($name, $token->getToken());
			
			$this->opt('token', $token);
			
			$this->addPhpValidation('required', '');
			$this->addPhpValidation('token', '', array($this->_token));
		}
		
	}
	
?>